// 初始化系统
define(['jquery', '_queryConditions'], function ($, _qc ){
    function setRandom() {
        var ran = Date.parse(new Date());
        if (!!$("#logo").get(0)) {
            document.getElementById('logo').setAttribute("href", "/?ran=" + ran);
        }
        var exitsys = function () {
            if (!window.swao) {
                return;
            }
            var version = "版本：V" + window.swao.version() + "\r\n";
            var str = prompt("退出系统？\r\n" + version + "退出密码~~~", "");
            if (str) {
                if (str == "805") {
                    window.swao.exit(0);
                }
                else if (str == "806") {
                    window.location.href = "/Home/DeviceLogin";
                }
            }
        };
        var listenToEvent = function () {
            var str = prompt("listenToEvent？", "");
            if (!str) {
                return;
            }
            if (str == "000") {
                window.location.href = "/Home/DeviceLogin";
            }
            else if (str == "111") {
                if (window.swao) {
                    window.swao.setScreenOrientationLandscape(true);
                }
                else {
                    alert('window.swao未找到！')
                }
            }
            else if (str == "222") {
                if (window.swao) {
                    window.swao.setScreenOrientationLandscape(false);
                }
                else {
                    alert('window.swao未找到！')
                }
            }
            else if (str == "test") {
                window.location.href = "/Test";
            }
            else if (str == "f5") {
                window.location.reload();
            }
            else if (str == "f5f5") {
                _qc.removeNetPoint();
                window.location.reload();
            }
            else {
                alert('非法命令！');
            }
            //else if (str=="page") {
            //    window.location.href = "/StaticPage/listenToEvent.html";
            //}
        };
        $("#exitsys").off("click").on("click", function () {
            exitsys();
        });
        $("#listenToEvent").off("click").on("click", function () {
            listenToEvent();
        });
    }
    function init() {
        setRandom();
        _qc.setCategoryId($("#categoryId").val());
        if (!!_qc.getNetPoint()) {
            $("#netPointNameShow").html(_qc.getNetPoint().name);
            $("#netPointAddressShow").html(_qc.getNetPoint().address);
        }
    }
    return {
        init: init
    }
});